import js from '@eslint/js'
import pluginVue from 'eslint-plugin-vue'
import eslintConfigPrettier from '@vue/eslint-config-prettier'
import globals from 'globals'

export default [
  {
    languageOptions: {
      ecmaVersion: 'latest', // 使用 'latest' 而不是 2022
      sourceType: 'module',
      globals: { ...globals.browser, ...globals.node }
    }
  },
  {
    name: 'app/files-to-lint',
    files: ['**/*.{js,mjs,jsx,vue}']
  },
  {
    name: 'app/files-to-ignore',
    ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**']
  },
  js.configs.recommended,
  ...pluginVue.configs['flat/essential'],
  eslintConfigPrettier,
  {
    rules: {
      'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', // 根据环境变量决定是否允许 console
      'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', // 根据环境变量决定是否允许 debugger
      'vue/multi-word-component-names': 'off',
      'vue/no-v-for-template-key': 'off',
      'no-irregular-whitespace': 'off',
      'linebreak-style': 'off'
    }
  }
]
